package 组合模式;


import java.util.ArrayList;
import java.util.List;

public class Folder extends AbstractFile {
    private String fileName;
    private List<AbstractFile> fileList=new ArrayList<>();//文件夹下的所有文件

    public Folder(String fileName) {
        this.fileName = fileName;
    }

    @Override
    public void add(AbstractFile file) {
        fileList.add(file);
    }

    @Override
    public void remove(AbstractFile file) {
        fileList.remove(file);
    }

    //输出当前文件夹名称和文件夹下所有文件名称
    @Override
    public void display() {
        System.out.println("-----------"+getFileName()+"----------------");
        for (AbstractFile abstractFile : fileList) {
            abstractFile.display();
        }
    }


    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public List<AbstractFile> getFileList() {
        return fileList;
    }

    public void setFileList(List<AbstractFile> fileList) {
        this.fileList = fileList;
    }

}
